
#ifndef __CMarketMgr_h__
#define __CMarketMgr_h__

#include "CTSizeString.h"
#include "CTArray.h"
#include "CTAsyncCmd.h"
#include "CTKeyValue.h"

class CTaskIDToStr
{
public:
    enum MyEnum
    {
        TENCENT_TASK_STR_LEN = 32,
    };  

    CTaskIDToStr ()
    {
        _uiTaskID = 0;
        _szTaskStr.Set("");
        
    }

    unsigned int _uiTaskID;
    CTLib::CTSizeString<TENCENT_TASK_STR_LEN> _szTaskStr;
};

class CPlayerOnlineData;
class CMarketTask;
class CReqApi;
class CUserTask;

class CMarketMgr
{
public:
    enum MyEnum
    {
        TENCET_TASK_ID_NUM = 100,

        TENCENT_MARKET_TASK_ID_1 = 9970001,
    };

    CMarketMgr() ;

    int LoadConfig(const char* szCfgPath);

    void InfomTaskCompleted (unsigned int uiGID);

    int GetInfomTaskCompletedPara (CMarketTask & stMarketTask, CPlayerOnlineData & stPlayerOnlineData, CReqApi & stApiReq);
        
    void CheckTaskStatus (CTLib::CTAsyncCmd * pstParent, CMarketTask & stMarketTask, unsigned int uiGID, CTLib::CTKeyValue & stTencentApiKeyValue);

    int CheckCompletion (CMarketTask & stMarketTask, CPlayerOnlineData & stPlayerOnlineData);

    int ProvideAward (CMarketTask & stMarketTask, CPlayerOnlineData & stPlayerOnlineData, unsigned int uiGiftID, int iCount);

    unsigned int GetTaskId (const char * pTaskStr);
    const char * GetContractStr (unsigned int uiTaskID);

    int AcceptTask (CMarketTask & stMarketTask, CPlayerOnlineData & stPlayerOnlineData);

    int CheckBeforOpt (CMarketTask & stMarketTask);

    int GetCheckTaskStatusPara (CMarketTask & stMarketTask, CPlayerOnlineData & stPlayerOnlineData, CReqApi & stApiReq);
private:
    CTLib::CTArray<CTaskIDToStr, TENCET_TASK_ID_NUM>  _astTaskIDToStr;
};

#endif // CMarketMgr
